﻿/*ajax*/
(function ($) {
    var ajax = {};
    /**
    * get 请求示例
    */
    ajax.get = function () {
        return $.ajax({
            url: "/example",
            type: "GET",
            async: true,
            data: {

            },
        });
    };
    /**
     * post 请求示例
     */
    ajax.post = function (id) {
        return $.ajax({
            url: "/api/services/Folder/CreateFolder",
            type: "post",
            data: {
            }
        });
    };
    /**
     * post json 请求示例
     */
    ajax.postJson = function (id) {
        return $.ajax({
            url: "/api/services/Folder/CreateFolder",
            type: "post",
            data: JSON.stringify({
                Name: folderName,
                ParentFolderId: parentFolderId,
            }),
            contentType: "application/json",
            processData: false,
        });
    };

    /**
     * addOnlineContainer
     */
    ajax.addOnlineContainer = function (areaName, key, data, expireSeconds = 600) {
        return $.ajax({
            url: "/api/OnlineContainer/Add",
            type: "post",
            data: JSON.stringify({
                "areaName": areaName,
                "key": key,
                "data": data,
                "expireSeconds": expireSeconds
            }),
            contentType: "application/json",
            processData: false,
        });
    };
    /**
    * get 请求示例
    */
    ajax.getOnlineContainerByArea = function (areaName) {
        return $.ajax({
            url: "/api/OnlineContainer/GetAll/" + areaName,
            type: "GET",
            async: true,
            data: null,
        });
    };
    window.ajax = ajax;
}
)(jQuery)